# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'stock.ui'
#
# Created: Wed Oct 07 16:43:04 2009
#      by: PyQt4 UI code generator 4.6
#
# WARNING! All changes made in this file will be lost!

from PyQt4 import QtCore, QtGui
from suds.client import Client
from BeautifulSoup import BeautifulStoneSoup

class Ui_Frame(object):
    def setupUi(self, Frame):
        Frame.setObjectName("Frame")
        Frame.resize(565, 418)
        Frame.setFrameShape(QtGui.QFrame.StyledPanel)
        Frame.setFrameShadow(QtGui.QFrame.Raised)
        self.textEdit = QtGui.QTextEdit(Frame)
        self.textEdit.setGeometry(QtCore.QRect(40, 70, 491, 281))
        self.textEdit.setObjectName("textEdit")
        self.lineEdit = QtGui.QLineEdit(Frame)
        self.lineEdit.setGeometry(QtCore.QRect(40, 30, 211, 20))
        self.lineEdit.setMaxLength(4)
        self.lineEdit.setObjectName("lineEdit")
        self.pushButton = QtGui.QPushButton(Frame)
        self.pushButton.setGeometry(QtCore.QRect(290, 30, 75, 23))
        self.pushButton.setObjectName("pushButton")

        self.retranslateUi(Frame)
        QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL("clicked()"), self.getQuote)
        QtCore.QMetaObject.connectSlotsByName(Frame)

    def retranslateUi(self, Frame):
        Frame.setWindowTitle(QtGui.QApplication.translate("Frame", "Stock Quote", None, QtGui.QApplication.UnicodeUTF8))
        self.lineEdit.setToolTip(QtGui.QApplication.translate("Frame", "Symbol", None, QtGui.QApplication.UnicodeUTF8))
        self.pushButton.setText(QtGui.QApplication.translate("Frame", "Get Quote", None, QtGui.QApplication.UnicodeUTF8))

    def getQuote(self):
        url = 'http://www.webservicex.net/stockquote.asmx?wsdl'
        c=Client(url)
        symbol = self.lineEdit.text()
        xml = c.service.GetQuote(symbol)
        soup = BeautifulStoneSoup(xml)
        self.textEdit.setText(soup.prettify())

if __name__ == "__main__":
    import sys
    app = QtGui.QApplication(sys.argv)
    Frame = QtGui.QFrame()
    ui = Ui_Frame()
    ui.setupUi(Frame)
    Frame.show()
    sys.exit(app.exec_())

